<template>
  <div class="container-pt">
    <van-nav-bar left-arrow @click-left="$router.back()" fixed title="列表" />
    <van-tabs v-model="active" animated swipeable>
      <van-tab v-for="item in allCateList" :key="item.id">
        <template #title> {{ item.catename }} </template>
        <article-list :cateid="item.id" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import articleList from "@/components/article-list-cate.vue";
import { getCateListApi } from "../api/article";
export default {
  components: { articleList },
  data() {
    return {
      active: 0,
      allCateList: [], // 所有分类
      currentCateId: "", // 当前的分类ID
    };
  },
  methods: {
    async getAllCateList() {
      const { data } = await getCateListApi();
      this.allCateList = data.allCate;
      // console.log(this.allCateList);
    },
  },
  // 调用方法
  created() {
    this.getAllCateList();
    //  获取顶部的分类
    this.active = this.$route.query.index * 1;
    this.currentCateId = this.$route.query.id;
  },
};
</script>

<style>
</style>